def traverse(tree):
    if len(tree) == 0:
        return []
    if len(tree) == 1:
        return tree

    n = len(tree)
    result = []
    root = 0
    def dfs(node):
        left = 2 * node + 1
        right = 2 * node + 2
        if left >= n:
            return
        elif right >= n:
            result.append(node)
        else:
            dfs(left)
            dfs(right)
            result.append(node)
    dfs(root)
    result = [tree[i] for i in result]
    return result


for i in range(20):
    print(i, traverse(list(range(i))))
